var timeout_json = function(data, $window) {
	if(data.returnCode == 999994) {
		var ss = 3;
		layer.msg(data.returnMessage + "！<strong class='Ajax_Out'>" + ss + "</strong> 秒后前往登录页", 50, -1);
		var picInt = setInterval(function() {
			if(ss >= 1) {
				ss = ss - 1;
				$('.Ajax_Out').text(ss);
			} else {
				clearInterval(picInt);
				try {
					$window.parent.location.href = data.returnData;
					$window.location.href = data.returnData;
				} catch(e) {
					log('timeout!')
				}
			}
		}, 1000);
		return false;
	}
}

//var getSs=function(v){
//	if(window.notChannels&&window.notChannels!="None"){
//		var cls=window.notChannels.split(',');
//		for(ii=0;ii<cls.length;ii++){
//			if(v==cls[ii]){
//				return false || ii;
//			}
//		}
//	}
//}
var getSs=function(reStr,v){
	if(reStr&&reStr!="None"){
		var cls=reStr.split(',');
		for(ii=0;ii<cls.length;ii++){
			if(v==cls[ii]){
				return false || ii;
			}
		}
	}
}

var app = angular.module("rscEditApp", []),
	ifm_id = UI.getParameterByName('ifm_id'),
	groupIde = UI.getParameterByName('groupId');
	
app.config(function($httpProvider) {
	$httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded';
	$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
	$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
});

app.controller('editCtrl', function($scope, $http, $window, $timeout) {
	var vm = $scope.vm = {
		ifm_id: null,
		ifm_name: null,
		ifm_pushed: 0,
		ifm_type: null,
		ifm_note: null,
		ifm_getChannel: null,
		ifm_notChannel: null,
		ifm_getWechatId: null,
		ifm_notWechatId: null,
		ifm_getBloggerId: null,
		ifm_notBloggerId: null,
		ifm_getBbsName: null,
		ifm_notBbsName: null,
		ifm_getKeyword: null,
		ifm_notKeyword: null,
		ifm_isdelete: null,
		ifm_matePattern: null,
		ifm_filterPattern: null,
		
	};
	
	$scope.domAjax = function(e) {
		if(e === "release") {
//			var ids = "";
//			var $selects = $(".editExaDataBtn");
//			$.each($selects, function(i, n) {
//				var dd = $(n).attr("ids");
//				if(i > 0) {
//					if(dd.length > 0) {
//						dd = "," + dd;
//					}
//				}
//				ids = ids + dd;
//			});
//			$scope.vm.rule_id = ids;
			
			function ifmParams(rscType,allSelectType,partSelectType,allFilterType,partFilterType,ifmGetType,ifmNotType,ifmGetTypes,ifmNotTypes){
				if(rscType.val()==allSelectType){
					$scope.vm[ifmGetType] = "All";
					$scope.vm[ifmNotType] = null;
				}
				if(rscType.val()==partSelectType){
//					$scope.vm.ifm_getChannel = $("#submitSelectNewsText").text();
					if (window[ifmGetTypes].substr(0,1)==','){window[ifmGetTypes] = window[ifmGetTypes].substr(1);}
					$scope.vm[ifmGetType] = window[ifmGetTypes];
					$scope.vm[ifmNotType] = null;
				}
				if(rscType.val()==allFilterType){
					$scope.vm[ifmNotType] = "All";
					$scope.vm[ifmGetType] = null;
				}
				if(rscType.val()==partFilterType){
//					$scope.vm.ifm_notChannel = $("#submitFilterNewsText").text();
					if (window[ifmNotTypes].substr(0,1)==','){window[ifmNotTypes] = window[ifmNotTypes].substr(1);}
					$scope.vm[ifmNotType] = window[ifmNotTypes];
					$scope.vm[ifmGetType] = null;
				}
			}
			//频道、微信、微博、论坛
			ifmParams($("#rscNews"),"allSelectNews","partSelectNews","allFilterNews","partFilterNews","ifm_getChannel","ifm_notChannel","getChannels","notChannels");
			ifmParams($("#rscWeChat"),"allSelectWeChat","partSelectWeChat","allFilterWeChat","partFilterWeChat","ifm_getWechatId","ifm_notWechatId","getWechatIds","notWechatIds");
			ifmParams($("#rscWeibo"),"allSelectWeibo","partSelectWeibo","allFilterWeibo","partFilterWeibo","ifm_getBloggerId","ifm_notBloggerId","getBloggerIds","notBloggerIds");
			ifmParams($("#rscBBS"),"allSelectBBS","partSelectBBS","allFilterBBS","partFilterBBS","ifm_getBbsName","ifm_notBbsName","getBbsNames","notBbsNames");

			var params = {
				ifm_id: $scope.vm.ifm_id,
				ifm_name: $scope.vm.ifm_name,
				ifm_pushed: $scope.vm.ifm_pushed,
				ifm_type: $scope.vm.ifm_type,
				ifm_note: $scope.vm.ifm_note,
				
				ifm_getChannel: $scope.vm.ifm_getChannel,
				ifm_notChannel: $scope.vm.ifm_notChannel,
				ifm_getWechatId: $scope.vm.ifm_getWechatId,
				ifm_notWechatId: $scope.vm.ifm_notWechatId,
				ifm_getBloggerId: $scope.vm.ifm_getBloggerId,
				ifm_notBloggerId: $scope.vm.ifm_notBloggerId,
				ifm_getBbsName: $scope.vm.ifm_getBbsName,
				ifm_notBbsName: $scope.vm.ifm_notBbsName,
				ifm_getKeyword: $scope.vm.ifm_getKeyword,
				ifm_notKeyword: $scope.vm.ifm_notKeyword,
				ifm_isdelete: $scope.vm.ifm_isdelete,
				ifm_matePattern: $scope.vm.ifm_matePattern,
				ifm_filterPattern: $scope.vm.ifm_filterPattern

			};
			$.ajax({
				type: "POST",
				url: basePath +'iformation/modifyIformation.do?discern=1',
				data: params,
				error: function(request) {
					layer.msg("操作失败，请刷新重试！", 2, -1);
				},
				success: function(data) {
					var j = timeout_json(data, $window);
					if(j == false) {
						return false;
					}
					if(data.returnCode == 10000) {
						layer.msg(data.returnMessage, 1, 10);
						//保存iframe窗口后，不跳转页面
						var t = setTimeout(function(){
							window.parent.$(".dtab").find('#jsgo a.cur').trigger('click');
							window.parent.layer.closeAll();
						},1000);
					} else {
						layer.msg(data.returnMessage, 2, -1);
						return false;
					}
				}
			});
		}
	};
	$scope.cancel = function(e) {
		window.parent.layer.closeAll();
	}
	//初始化数据
	$scope.initData = function(e) {
	
		if($("#rscNews").val()=="partSelectNews"){
			$("#p_newsDiv").css("display","block");
		}else if($("#rscNews").val()=="partFilterNews"){
			$("#f_newsDiv").css("display","block");
		}else if($("#rscWeChat").val()=="partSelectWeChat"){
			$("#p_wechatDiv").css("display","block");
		}else if($("#rscWeChat").val()=="partFilterWeChat"){
			$("#f_wechatDiv").css("display","block");
		}else if($("#rscWeibo").val()=="partSelectWeibo"){
			$("#p_weiboDiv").css("display","block");
		}else if($("#rscWeibo").val()=="partFilterWeibo"){
			$("#f_weiboDiv").css("display","block");
		}else if($("#rscBBS").val()=="partSelectBBS"){
			$("#p_webbsDiv").css("display","block");
		}else if($("#rscBBS").val()=="partFilterBBS"){
			$("#f_webbsDiv").css("display","block");
		}
		
		function ifmInitDrop(ifmGetType,ifmNotType,allSelectTypeObj,partSelectTypeObj,allFilterTypeObj,partFilterTypeObj){
			if(vm[ifmGetType] != null && vm[ifmGetType] != undefined && vm[ifmGetType] != ""||vm[ifmNotType] != null && vm[ifmNotType] != undefined && vm[ifmNotType] != "") {
				var ifmGetTypeStr = vm[ifmGetType];
				var ifmNotTypeStr = vm[ifmNotType];
				if(ifmGetTypeStr=="All"){
					allSelectTypeObj.trigger('click');
					$('.ui_s_bk').css('display','none');
				}else if((ifmGetTypeStr!="All")&&(ifmGetTypeStr!="None")){
					partSelectTypeObj.trigger('click');
					$('.ui_s_bk').css('display','none');
				}else if(ifmNotTypeStr=="All"){
					allFilterTypeObj.trigger('click');
					$('.ui_s_bk').css('display','none');
				}else if((ifmNotTypeStr!="All")&&(ifmNotTypeStr!="None")){
					partFilterTypeObj.trigger('click');
					$('.ui_s_bk').css('display','none');
				}
			}
		}
		//初始下拉框的选项内容展示
		ifmInitDrop("ifm_getChannel","ifm_notChannel",$('#allSelectNewsSpan'),$('#partSelectNewsSpan'),$('#allFilterNewsSpan'),$('#partFilterNewsSpan'));
		ifmInitDrop("ifm_getWechatId","ifm_notWechatId",$('#allSelectWeChatSpan'),$('#partSelectWeChatSpan'),$('#allFilterWeChatSpan'),$('#partFilterWeChatSpan'));
		ifmInitDrop("ifm_getBloggerId","ifm_notBloggerId",$('#allSelectWeiboSpan'),$('#partSelectWeiboSpan'),$('#allFilterWeiboSpan'),$('#partFilterWeiboSpan'));
		ifmInitDrop("ifm_getBbsName","ifm_notBbsName",$('#allSelectBBSSpan'),$('#partSelectBBSSpan'),$('#allFilterBBSSpan'),$('#partFilterBBSSpan'));
	}

	//查询数据初始化
	if(ifm_id != undefined) {
		$http.get(basePath + 'iformation/queryByID2.do?ifm_id=' + ifm_id + '&groupId=' + groupIde).success(function(data) {
			var j = timeout_json(data, $window);
			if(j == false) {
				return false;
			}
			if(data.returnCode == 10000) {
				vm = $scope.vm = data.returnData;
				window.getChannels=data.returnData.ifm_getChannel;
				window.notChannels=data.returnData.ifm_notChannel;
				window.getWechatIds=data.returnData.ifm_getWechatId;
				window.notWechatIds=data.returnData.ifm_notWechatId;
				window.getBloggerIds=data.returnData.ifm_getBloggerId;
				window.notBloggerIds=data.returnData.ifm_notBloggerId;
				window.getBbsNames=data.returnData.ifm_getBbsName;
				window.notBbsNames=data.returnData.ifm_notBbsName;
				if(window.getChannels=="None"||window.getChannels=="undefined"){window.getChannels=""}
				if(window.notChannels=="None"||window.notChannels=="undefined"){window.notChannels=""}
				if(window.getWechatIds=="None"||window.getWechatIds=="undefined"){window.getWechatIds=""}
				if(window.notWechatIds=="None"||window.notWechatIds=="undefined"){window.notWechatIds=""}
				if(window.getBloggerIds=="None"||window.getBloggerIds=="undefined"){window.getBloggerIds=""}
				if(window.notBloggerIds=="None"||window.notBloggerIds=="undefined"){window.notBloggerIds=""}
				if(window.getBbsNames=="None"||window.getBbsNames=="undefined"){window.getBbsNames=""}
				if(window.notBbsNames=="None"||window.notBbsNames=="undefined"){window.notBbsNames=""}
			}
			$scope.initData();
		});
	} 
});

$(function() {
	laydate.skin('molv');
	$('.ui_select').each(function() {
		var _ = $(this),
			_a = _.find('.ui_s_t'),
			_c = _.find('.ui_s_bk'),
			_ca = _c.find('a');
		_a.live('click', function() {
			_c.slideToggle(200, "easeInSine");
		});
		_ca.live('click', function() {
			$(this).addClass('cur').siblings().removeClass('cur');
			_a.text($(this).text());
//			根据不同的选项，展现不同的选择标签按钮
			$(this).parent().siblings("input").val($(this).attr("type"));
			_c.slideToggle(200, "easeInSine");
			var selectTag = $(this).parent().siblings("input").val();
			if(selectTag=="partSelectNews"){
				$("#f_newsDiv").css("display","none");
				$("#p_newsDiv").css("display","block");
			}else if(selectTag=="partFilterNews"){
				$("#p_newsDiv").css("display","none");
				$("#f_newsDiv").css("display","block");
			}else if(selectTag=="partSelectWeChat"){
				$("#f_wechatDiv").css("display","none");
				$("#p_wechatDiv").css("display","block");
			}else if(selectTag=="partFilterWeChat"){
				$("#p_wechatDiv").css("display","none");
				$("#f_wechatDiv").css("display","block");
			}else if(selectTag=="partSelectWeibo"){
				$("#f_weiboDiv").css("display","none");
				$("#p_weiboDiv").css("display","block");
			}else if(selectTag=="partFilterWeibo"){
				$("#p_weiboDiv").css("display","none");
				$("#f_weiboDiv").css("display","block");
			}else if(selectTag=="partSelectBBS"){
				$("#f_bbsDiv").css("display","none");
				$("#p_bbsDiv").css("display","block");
			}else if(selectTag=="partFilterBBS"){
				$("#p_bbsDiv").css("display","none");
				$("#f_bbsDiv").css("display","block");
			}else{
				$(this).parent().parent().siblings("div").css("display","none");
			}
		});
		_c.live('mouseleave', function() {
			_c.stop(false, true).slideUp(200, "easeInSine");
		});
	});

	$('.ui_select').live('keyup', function(e) {
		var _ = $(this),
			b = _.find('.ui_s_bk'),
			di = 27;
		_.focus();
		e = e || window.event;
		var indx = b.find('a.cur').index() || 0;
		if(e.keyCode == 40) {
			var aindx = indx + 1,
				sct;
			if(rindx >= b.find('a').length) {
				rindx = b.find('a').length;
			}
			b.find('a').eq(aindx).addClass('cur').siblings('a').removeClass('cur');
			sct = aindx * di > 180 ? aindx * di - 80 : 0;
			b.scrollTop(sct);
		} else if(e.keyCode == 38) {
			var rindx = indx - 1,
				sct;
			sct = aindx * di > 100 ? aindx * di : 0;
			if(rindx <= 0) {
				rindx = 0;
			}
			b.find('a').eq(rindx).addClass('cur').siblings('a').removeClass('cur');
			sct = rindx * di > 180 ? rindx * di - 80 : 0;
			b.scrollTop(sct);
		} else if(e.keyCode == 13) {
			b.find('a.cur').trigger('click');
			_.blur();
			_.find('.ui_s_t').blur();
		}
		return false;
	});
	//open edit Layer
	var editExaDataLayer = null;
	var queryType;
//	var pagePlugn={}
	$('.editExaDataBtn').live('click', function() {
		var editExaDataLayer = $.layer({
			type: 1,
			title: false,
			area: ['900', '100%'],
			border: [0], //去掉默认边框
			shade: [0.3, '#000'], //去掉遮罩
			closeBtn: [0, false], //去掉默认关闭按钮
			fadeIn: 500,
			move: "#editExaData_tile",
			page: {
				dom: '#editExaDataLayer'
			}
		});
		$(this).addClass("cL");
		//自设关闭
		$('#editExaDataLayer > .closeBtn,#editExaDataLayer .cancelLayer').live('click', function() {
			layer.close(editExaDataLayer);
			curPage=1;
			$('.editExaDataBtn').removeClass("cL");
			$('#checkQueryInput').val('');
		});
	});

	var edit = {
		"qRscList": function(_this, rscArr, queryValue, pIndex, numList, selectJson) {
			var queryUrl = {
				p_newsType: "channel/queryChannelByType.do",f_newsType: "channel/queryChannelByType.do",
				p_wechatType: "weixin/queryWeixinByType.do",f_wechatType: "weixin/queryWeixinByType.do",
				p_weiboType: "microuser/queryMicroserByType.do",f_weiboType: "microuser/queryMicroserByType.do",
				p_bbsType: "channel/queryChannelByType.do",f_bbsType: "channel/queryChannelByType.do"
			};
			if(isNaN(numList)){
				numList=5000;
			}
			var queryParams = {
					p_newsType: {
						ifm_id:ifm_id,
						channel_type:"News",
						pageIndex: pIndex,
						pageSize: numList,
						channel_name:selectJson.channel_name,
						types:queryType
					},
					f_newsType: {
						ifm_id:ifm_id,
						channel_type:"News",
						pageIndex: pIndex,
						pageSize: numList,
						channel_name:selectJson.channel_name,
						types:queryType
					},
					p_wechatType: {
						ifm_id:ifm_id,
						pageIndex: pIndex,
						pageSize: numList,
						weixin_name:selectJson.weixin_name,
						types:queryType
					},
					f_wechatType: {
						ifm_id:ifm_id,
						pageIndex: pIndex,
						pageSize: numList,
						weixin_name:selectJson.weixin_name,
						types:queryType
					},
					p_weiboType: {
						ifm_id:ifm_id,
						pageIndex: pIndex,
						pageSize: numList,
						microuser_blogger:selectJson.microuser_blogger,
						types:queryType
					},
					f_weiboType: {
						ifm_id:ifm_id,
						pageIndex: pIndex,
						pageSize: numList,
						microuser_blogger:selectJson.microuser_blogger,
						types:queryType
					},
					p_bbsType: {
						ifm_id:ifm_id,
						channel_type:"BBS",
						pageIndex: pIndex,
						pageSize: numList,
						channel_name:selectJson.channel_name,
						types:queryType
					},
					f_bbsType: {
						ifm_id:ifm_id,
						channel_type:"BBS",
						pageIndex: pIndex,
						pageSize: numList,
						channel_name:selectJson.channel_name,
						types:queryType
					}
				};
			var showTypeParams = {
				p_newsType: {
					name: "channel_name",
					id:"channel_id"
				},
				f_newsType: {
					name: "channel_name",
					id:"channel_id"
				},
				p_wechatType: {
					name: "weixin_name",
					id:"weixinuser_Id"
				},
				f_wechatType: {
					name: "weixin_name",
					id:"weixinuser_Id"
				},
				p_weiboType: {
					name: "microuser_blogger",
					id:"microuser_bloggerId"
				},
				f_weiboType: {
					name: "microuser_blogger",
					id:"microuser_bloggerId"
				},
				p_bbsType: {
					name: "channel_name",
					id:"channel_id"
				},
				f_bbsType: {
					name: "channel_name",
					id:"channel_id"
				}
			};
			var resStrParams = {
				p_newsType: {
					content: window.getChannels
				},
				f_newsType: {
					content: window.notChannels
				},
				p_wechatType: {
					content: window.getWechatIds
				},
				f_wechatType: {
					content: window.notWechatIds
				},
				p_weiboType: {
					content: window.getBloggerIds
				},
				f_weiboType: {
					content: window.notBloggerIds
				},
				p_bbsType: {
					content: window.getBbsNames
				},
				f_bbsType: {
					content: window.notBbsNames
				}
			};
			
			var _obj = $(".ktab");
			$.ajax({
				type: "POST",
				url: basePath + queryUrl[eval('queryType')],
				data: queryParams[eval('queryType')],
				success: function(data) {
					if(data.returnCode == 10000) {
						var s2 = data.returnData.length;
						var showTypeParamName = showTypeParams[eval('queryType')].name;
						var showTypeParamId = showTypeParams[eval('queryType')].id;
						var resStrParam = resStrParams[eval('queryType')].content;
						if(s2 > 0) {
							var htmls = "";
							var checkedHtmls = "";
							var htmlEnd="";
							for(var i = 0; i < s2; i++) {
								var checkedBtn = "";
								var checked = "";
								var channelName2 = data.returnData[i][eval("showTypeParamName")];
								var channelId2 = data.returnData[i][eval("showTypeParamId")];
								var checkeddefault = "";
								var num = rscArr.length;
								//频道、论坛
								if(queryType.indexOf("news")>0||queryType.indexOf("bbs")>0){
									for(var nn = 0; nn < num; nn++) {
										if(getSs(resStrParam,channelName2)||getSs(resStrParam,channelName2)==0) {
											checkedBtn = "true";
											checked = "checked";
											checkeddefault = "true";
											break;
										} else {
											checkedBtn = "false";
											checkeddefault = "false";
											checked = "";
										}
									}
								}

								//微信号、微博号
								if(queryType.indexOf("wechat")>0||queryType.indexOf("weibo")>0){
									for(var nn = 0; nn < num; nn++) {
										if(getSs(resStrParam,channelId2)||getSs(resStrParam,channelId2)==0) {
											checkedBtn = "true";
											checked = "checked";
											checkeddefault = "true";
											break;
										} else {
											checkedBtn = "false";
											checkeddefault = "false";
											checked = "";
										}
									}
								}
							
//								if(getSs(channelName2)) {
								checkedHtmls += "<div class='infoLlist w440 fl' title='" + data.returnData[i][eval("showTypeParamName")] + "'><span class='ui_checkbox " + checked + "' t-name= '" + data.returnData[i][eval("showTypeParamName")] + "' t-id= '" + data.returnData[i][eval("showTypeParamId")] +  "' checkedBtn='" + checkedBtn + "' checkeddefault='" + checkeddefault + "'></span> <font>" + data.returnData[i][eval("showTypeParamName")] + "</font></div>";
//								} else {
//									选中与未选中分开展示
//									htmls += "<div class='infoLlist fl w300' title='" + data.returnData[i][eval("showTypeParamName")] + "'><span class='ui_checkbox " + checked + "' t-name= '" + data.returnData[i][eval("showTypeParamName")] + "' checkedBtn='" + checkedBtn + "' checkeddefault='" + checkeddefault + "'></span> <font>" + data.returnData[i][eval("showTypeParamName")] + "</font></div>";
//								}
							}
							var strPage = "<div class='pages' style='position:relative;top:6px;'><div class='ui_page' id='pageArea'></div></div>";
							 
//							$("#checkQueryInput").val("");
							$("#editExaData_tile").text(_this.attr("title") + "列表");
							if(_this.attr("title")=="选择频道"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partSelectNews");
							}else if(_this.attr("title")=="过滤频道"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partFilterNews");
							}else if(_this.attr("title")=="选择微信号"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partSelectWeChat");
							}else if(_this.attr("title")=="过滤微信号"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partFilterWeChat");
							}else if(_this.attr("title")=="选择微博号"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partSelectWeibo");
							}else if(_this.attr("title")=="过滤微博号"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partFilterWeibo");
							}else if(_this.attr("title")=="选择论坛"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partSelectBBS");
							}else if(_this.attr("title")=="过滤论坛"){
								$("#hiddenType").val("");
								$("#hiddenType").val("partFilterBBS");
							}
						
							$("#editExaData_listName").text(_this.attr("title").substring(2) + "名称");
							_obj.html(checkedHtmls + htmls + "<div class='clear'></div>");
							$(".pageDiv").html(strPage);
							paging.loadPage(data);
							checkTrueFalse();
						}
						if(s2 < 1) {
							_obj.html("<br><bR><p align='center'>很遗憾，没有查询到相关的数据！</p><br><bR>");
						}
					} else if(data.returnCode == 999994) {
						setUserTimeout(data);
					} else {
						layer.msg(data.returnMessage, 2, -1);
					}
				},
				error: function(message) {
					layer.msg("操作失败，请重试！", 2, -1);
				},
				beforeSend: function() {
					var imgGif = "<p class='loadingGif'></p>";
					_obj.html(imgGif);
				}
			});
		}
//		"queryCheck": function(names) {
//			var $selectShowSpan = $(".editExaDataBtn[type='" + queryType + "']");
//			var $showSpan = $selectShowSpan.parent().prev("span");
////			$selectShowSpan.attr({
////				ids: ids
////			});
//			$showSpan.attr({
//				"title": names
//			});
//			$showSpan.text(names);
//		}
	}

	$(".infoLlist .ui_checkbox").live("click", function() {
		var selectTags = $("#hiddenType").val();
		if($(this).attr("checkedBtn") == "true") {
//			console.log($(this).context.getAttribute("t-name"));
			$(this).attr("checkedBtn", "false");
			$(this).removeClass("checked");
			
			function selectTagFunc(selectTag,selectType,objCur){
				if(selectTags==selectTag){
					if(selectType.indexOf("Ids") > 0){
						var qc=getSs(window[selectType],objCur.attr("t-id"));
					}else{
						var qc=getSs(window[selectType],objCur.attr("t-name"));
					}
					if(qc||qc==0){
						var typeArr=window[selectType].split(',');
						typeArr.splice(qc,1);
						window[selectType]=typeArr.join(',');
					}
				}
			}
			selectTagFunc("partSelectNews","getChannels",$(this));
			selectTagFunc("partFilterNews","notChannels",$(this));
			selectTagFunc("partSelectWeChat","getWechatIds",$(this));
			selectTagFunc("partFilterWeChat","notWechatIds",$(this));
			selectTagFunc("partSelectWeibo","getBloggerIds",$(this));
			selectTagFunc("partFilterWeibo","notBloggerIds",$(this));
			selectTagFunc("partSelectBBS","getBbsNames",$(this));
			selectTagFunc("partFilterBBS","notBbsNames",$(this));
		} else {
			$(this).attr("checkedBtn", "true");
			$(this).addClass("checked");
			
			function selectTagsFunc(selectTag,selectType,objCur){
				if(selectTags==selectTag){
					if(selectType.indexOf("Ids")>0){
						var qc=getSs(window[selectType],objCur.attr("t-id"));
					}else{
						var qc=getSs(window[selectType],objCur.attr("t-name"));
					}
					if(!qc){
						if(window[selectType]=="All"){
							window[selectType]="";
						}
						if(selectType.indexOf("Ids")>0){
							window[selectType] += (','+objCur.attr("t-id"));
						}else{
							window[selectType] += (','+objCur.attr("t-name"));
						}
					}
				}
			}
			selectTagsFunc("partSelectNews","getChannels",$(this));
			selectTagsFunc("partFilterNews","notChannels",$(this));
			selectTagsFunc("partSelectWeChat","getWechatIds",$(this));
			selectTagsFunc("partFilterWeChat","notWechatIds",$(this));
			selectTagsFunc("partSelectWeibo","getBloggerIds",$(this));
			selectTagsFunc("partFilterWeibo","notBloggerIds",$(this));
			selectTagsFunc("partSelectBBS","getBbsNames",$(this));
			selectTagsFunc("partFilterBBS","notBbsNames",$(this));
		}
	});
	$(".editExaDataBtn").live("click", function() {
//		var rscArr =  $(this).attr("ids").split(",");
		var rscArr =  $(this).parent().prev().text().split(",");
		queryType = $(this).attr('type');
		var params={};
		subPage=0;
		numList=10;
		edit.qRscList($(this), rscArr, params, 1, numList, "");
	});
		
	//全选
	$(".selectAllAreaGoGo .allSel").live("click", function() {
		var checkedbtn = $(this).attr("checkedbtn");
		var selectTags = $("#hiddenType").val();
		var len = $(".infoLlist .ui_checkbox").length;
		//判断在点击全选按钮之前，列表中是否存在已勾选的状态
		for(var ii=0;ii<len;ii++){
			if($(".infoLlist .ui_checkbox").eq(ii).attr("checkedbtn")=="true"){
				$(".infoLlist .ui_checkbox").eq(ii).attr("data-select","true");
			}else{
				$(".infoLlist .ui_checkbox").eq(ii).removeAttr("data-select");
			}
		}
		if(checkedbtn == "false") {
			$(".infoLlist .ui_checkbox,.allSel").addClass("checked").attr("checkedbtn", "true");
			
			function allSelectFunc(selectTag,selectType){
				if(selectTags==selectTag){
//					window[selectType]="";
					for(var i=0;i<len;i++){
						if(selectType.indexOf("Ids")>0){
							if($(".infoLlist .ui_checkbox").eq(i).attr("data-select")=="true"){
								var	nn="";
							}else{
								var nn= $(".infoLlist .ui_checkbox").eq(i).attr("t-id");
							}
						}else{
							if($(".infoLlist .ui_checkbox").eq(i).attr("data-select")=="true"){
								var nn="";
							}else{
								var nn= $(".infoLlist .ui_checkbox").eq(i).attr("t-name");
							}
						}
						var qc=getSs(window[selectType],nn);
						if(!qc){
							if(window[selectType]=="All"){
								window[selectType]="";
							}
							window[selectType]+=(nn!="" ? (',' + nn) : nn);
						}
					}
				}
			}
			allSelectFunc("partSelectNews","getChannels");
			allSelectFunc("partFilterNews","notChannels");
			allSelectFunc("partSelectWeChat","getWechatIds");
			allSelectFunc("partFilterWeChat","notWechatIds");
			allSelectFunc("partSelectWeibo","getBloggerIds");
			allSelectFunc("partFilterWeibo","notBloggerIds");
			allSelectFunc("partSelectBBS","getBbsNames");
			allSelectFunc("partFilterBBS","notBbsNames");
	
		} else {
			$(".infoLlist .ui_checkbox,.allSel").removeClass("checked").attr("checkedbtn", "false");
			
			function allSelectsFunc(selectTag,selectType){
				if(selectTags==selectTag){
					for(var i=0;i<len;i++){
						if(selectType.indexOf("Ids")>0){
							var nn= $(".infoLlist .ui_checkbox").eq(i).attr("t-id");
						}else{
							var nn= $(".infoLlist .ui_checkbox").eq(i).attr("t-name");
						}
						var qc=getSs(window[selectType],nn);
						if(qc||qc==0){
							var getChannelsArr=window[selectType].split(',');
								getChannelsArr.splice(qc,1);
							window[selectType]=getChannelsArr.join(',');
						}
					}
				}
			}
			allSelectsFunc("partSelectNews","getChannels");
			allSelectsFunc("partFilterNews","notChannels");
			allSelectsFunc("partSelectWeChat","getWechatIds");
			allSelectsFunc("partFilterWeChat","notWechatIds");
			allSelectsFunc("partSelectWeibo","getBloggerIds");
			allSelectsFunc("partFilterWeibo","notBloggerIds");
			allSelectsFunc("partSelectBBS","getBbsNames");
			allSelectsFunc("partFilterBBS","notBbsNames");

		}
	});
	//只要有选项没被选中，那么全选就不会出现选中状态
	$(".infoLlist .ui_checkbox").live("click", function() {
		checkTrueFalse();
	});

	function checkTrueFalse() {
		var isTrue = "true";
		$(".infoLlist .ui_checkbox").each(function() {
			var checkedbtn = $(this).attr("checkedbtn");
			if(checkedbtn == "false") {
				isTrue = "false";
				return;
			}
		});
		if(isTrue == "false") {
			$(".selectAllAreaGoGo .allSel").removeClass("checked").attr("checkedbtn", "false");
		} else {
			$(".selectAllAreaGoGo .allSel").addClass("checked").attr("checkedbtn", "true");
		}
	}

	//点击查询
	$("#checkQueryBtn").live("click", function() {
		curPage = 1;
		qDataFun(curPage);
	});
	$('.enterKeyDownElement').keydown(function(e) {
		if(e.keyCode == 13) {
			curPage = 1;
			qDataFun(1);
		}
	});
	//点击触发换页的按钮
	$("#pageArea .pNumBtn  a").live("click", function() {
		curPage = parseInt($(this).attr("toPage"));
		qDataFun(curPage);
	});

	//点击触发分批显示的按钮
	$("#pageArea .columnsPage a").live("click", function() {
		numList = parseInt($(this).text());
		curPage = 1;
		qDataFun(curPage);
		subPage = $(this).index();
	});
	//跳转
	$("#pageArea .gopg .btn").live("click", function() {
		curPage = parseInt($("#pageArea .gopg .txt").val());
		//判断输入的页数是否大于最大的页数
		if(curPage>countPage){
			curPage=countPage;
		}
		if(curPage>0){
			qDataFun(curPage);
		}
	});

	function qDataFun(curPages) {
		channel_name_text = $("#checkQueryInput").val();
		weixin_name_text = $("#checkQueryInput").val();
		microuser_blogger_text = $("#checkQueryInput").val();
		selectJsonData = null;
		selectJsonData = {
			channel_name: channel_name_text,
			weixin_name: weixin_name_text,
			microuser_blogger: microuser_blogger_text
		};
//		var rscArr2 =  $(".editExaDataBtn").attr("ids").split(",");
		var rscArr2 =  $(".cL").parent().prev().text().split(",");
		var params={};
		edit.qRscList($(".cL"), rscArr2, params, curPages, numList, selectJsonData);
	};
});

